package com.dbsync.core;

import com.dbsync.exception.DbsyncException;

/**
 * 基础类
 */
public class Base {
    // 数据库地址
    protected String url;
    // 数据用户名
    protected String username;
    // 数据库用户密码
    protected String password;
    // 数据库驱动完整包名
    protected String driverClassName;

    // 获取数据库类型
    public String getType() throws DbsyncException{
        if (this.driverClassName.contains("mysql")){
            return "mysql";
        }else if (this.driverClassName.contains("oracle")){
            return "oracle";
        }else if (this.driverClassName.contains("sqlserver")){
            return "sqlserver";
        }else if (this.driverClassName.contains("sybase")){
            return "sybase";
        }else if (this.driverClassName.contains("db2")){
            return "db2";
        }else{
            throw new DbsyncException("未支持的数据库类型，请检查配置文件中\"url\"地址是否为程序支持的数据库类型地址");
        }
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDriverClassName() {
        return driverClassName;
    }

    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }
}
